/**
 * Copyright (c) 2018, wuxie All rights reserved.
 * qq:16349023,mail:16349023@qq.com
 * 未经许可禁止任何人通过任何渠道使用、修改源代码.
 * 项目名称 : wxcloud
 *
 * @version V1.0
 */
package cn.xo68.boot.auth.server.util;

import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 *  认证服务工具类
 * @author wuxie
 * @date 2018/8/5 9:33
 *
 */
@Component
public class AuthServerUtils {

    /**
     * 构建认证服务端响应头
     * @param otherHeaders
     * @return
     */
    public HttpHeaders buildHeaders(Map<String,String> otherHeaders){
        HttpHeaders headers = new HttpHeaders();
        //cors
        headers.add("Access-Control-Allow-Origin", "*");

        //禁止缓存
        headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
        headers.add("Pragma", "no-cache");

        if(otherHeaders!=null){
            for(Map.Entry<String, String> map: otherHeaders.entrySet()){
                headers.add(map.getKey(),map.getValue());
            }
        }

        return headers;
    }
}
